public class java0810<T> {
     public Object[] array = new Object[5];//成员变量

    public void set(int a,T b){ //赋值
      this.array[a] = b;
    }
    public T get(int c){
        return (T)array[c]; //注意这里的变动
    }


    public static void main(String[] args) {
        java0810<Integer> x1 = new java0810<>();//规定了存放数据的类型
        x1.set(0,1);
        x1.set(1,2);
        int y1 = x1.get(0);
        int y2 = x1.get(1);
        System.out.println(y1);
        System.out.println(y2);

        java0810<String> x2 = new java0810<>();
        x2.set(0,"巨浪");
        x2.set(1,"M14大人");
        String y3 = x2.get(0);
        String y4 = x2.get(1);
        System.out.println(y3);
        System.out.println(y4);
    }



    public static void main1(String[] args) {
         java0810 x = new java0810();
         x.set(0,"哈哈");
         x.set(1, 2);

         String y1 = (String) x.get(0);
         int y2 = (int) x.get(1);  //需要强转，因为是object类型

        System.out.println(y1);
        System.out.println(y2);
    }



}
